/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication1;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 *
 * @author new
 */
public class PubExtHandler {

    public int delPubExt(String FileName) throws FileNotFoundException, IOException{
        String temp = "PubExtTemp";
        FileHandler fh = new FileHandler();
        BufferedReader br = fh.openReadFile(FileName);
        BufferedWriter bw = fh.openWriteFile(temp);
        String tempStr = br.readLine();
        while(tempStr != null){
            if(tempStr.contains("PUBLIC") || tempStr.contains("EXTERN")){
                tempStr = br.readLine();
                continue;
            }
            bw.append(tempStr);
            bw.newLine();
            tempStr = br.readLine();
        }
        fh.closeReadFile(br);
        fh.closeWriteFile(bw);
        System.gc();
        fh.replaceFile(temp, FileName);
        return 0;
    }

}
